<%-- 
    Document   : formEmpEc
    Created on : 18 mars 2013, 13:06:38
    Author     : ali
--%>

<%@page import="EDT.obj.Ec"%>
<%@page import="java.util.HashMap"%>
<%@page import="EDT.obj.Formation"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                
        <title>Emplois du temps EC form</title>
            <link rel="stylesheet" href="Accueil.css" />
            <link rel="SHORTCUT ICON" href="./edt.jpg" />
    </head>


    <body>    
         
    <section>
      

        

        
         
    <!--<form method='POST' action='PromoNivGradForm.do'> -->
   <%
     String form ="";
    ArrayList<Formation> formation = new ArrayList<Formation>();
    
    if(session.getAttribute("formation") == null || request.getParameter("formation")==null){
        
        formation = EDT.api.API.getFormation();
        session.setAttribute( "formation", formation );
        form += "<form method='POST' action='ConsultEmploiEC.do' target='section'>";
        form += "<div class='commentaire'>";
        form += "<fieldset>";
        
        
        form +="<legend>    Choisissez une formation  :   </legend>";
        form +="Formation : <select name='formation'>";
        for (Formation f : formation)
        form +="    <option value='"+f.getNom()+"'>"+f.getNom()+"</option>";
        form +="</select><br/><br/>";
        
        
        
               }else{
        
        formation = (ArrayList<Formation> ) session.getAttribute("formation");
        
        form +="<form method='POST' action='EmpEc.do' target='section'>\n";
        form += "<div class='commentaire'>\n";
        form += "<fieldset>";
        
        
        
        form += "<legend> Choisissez un Ec :   </legend>";
        
        String s = request.getParameter("formation");
        form += "<input type='hidden' name='formation' value='"+s+"'/>"; 
        
       
 
        
        for (Formation f : formation)
            if (f.getNom().equals(s)){
                ArrayList<Ec> ecs = EDT.api.API.getEC(f.getId());
                form += "Les ECs :   <select name='ec'>";
                for (Ec ec : ecs)
                    form += "<option value='"+ec.getId()+"'>"+ec.getNom()+"</option>";
                form += "</select><br/><br/>";
                
                 form += "Promotion : <select name='promotion'>";
                HashMap<Integer, Integer> hashMap = f.getLesPromos();
                for (Integer mapKey : hashMap.keySet()){
                    form += "<option value='"+mapKey+"'>"+hashMap.get(mapKey)+"/"+(hashMap.get(mapKey)+1)+"</option>";
                }
                    form += "</select><br/><br/>";
                
                
                
            }             

           
            
        session.removeAttribute("formation");
                       
               
                       
               }
    
        form +="<input type='submit' value='valider'/><br/>";
        out.println(form);
            
    %>
    
   
    
    
    <html:errors/> 
    
    </fieldset>
    
        
    </div>

    </form>
         
    </section>
    </body>
</html>